package com.itheima.service.mongo.impl;

import com.itheima.domain.mongo.FocusUser;
import com.itheima.service.mongo.FocusUserService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

@DubboService
public class FocusUserServiceimpl implements FocusUserService {
    @Autowired
    private MongoTemplate mongoTemplate;
    //关注
    @Override
    public void saveFocusUser(FocusUser focusUser) {
        mongoTemplate.save(focusUser);
    }
    //取消关注
    @Override
    public void removeFocusUser(Long userId, Long focusUserId) {
        Query query = Query.query(Criteria.where("userId").is(userId).and("FocusUserId").is(focusUserId));
        mongoTemplate.remove(query,FocusUser.class);


    }
}
